package SiTuQingYou.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import SiTuQingYou.dao.SceneClassDao;
import SiTuQingYou.dao.SceneDao;
import SiTuQingYou.dao.ScenePhotoDao;
import SiTuQingYou.util.Pager;
import SiTuQingYou.vo.Scene;
import SiTuQingYou.vo.SceneClass;

/**
 * Servlet implementation class ShowClassSceneServlet
 */
@WebServlet("/ShowClassSceneServlet")
public class ShowClassSceneServlet extends BaseAction {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ShowClassSceneServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	
	//ͨ�������idѰ�Ҿ���
	protected void getSceneByThemeId(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Pager pager =  Pager.init(request);
		String id=request.getParameter("id");
		 int sid=Integer.parseInt(id);
		 ArrayList<Scene>scenes=SceneDao.getscened().getAllSceneByThemeId(sid,pager);
		 request.setAttribute("scenes", scenes);
		 ArrayList<String> pics = new ArrayList<String>();
		 for(int i=0;i<scenes.size();i++)
			{
				int idd = scenes.get(i).getId();
				String pic = ScenePhotoDao.getspd().getfirstphotobyscenesid(idd);
			 
				pics.add(pic);
				
			}
			request.setAttribute("pics", pics);
		 
	 
	}
	protected void  showsceneclass(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 ArrayList<SceneClass> scs=SceneClassDao.getscd().getsceneclass();
		 request.setAttribute("scs", scs);
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	@Override
	protected void doDefault(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stubr
		
	}
}
